// Learn TypeScript:
//  - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html

const {ccclass, property} = cc._decorator;
//import {globalMember} from "./global";

@ccclass
export default class NewClass extends cc.Component {

    @property
    toLeft: boolean = true;

    @property
    toUp: boolean = true;

    @property
    toRight: boolean = true;

    @property
    toDown: boolean = true;

    //can_move: boolean = true; 

    dia: cc.Node = null;

    dialogScript: cc.Component = null;
   
   
    // LIFE-CYCLE CALLBACKS:

    onLoad () {
        this.node.on('touchstart', this.onClicked, this);
    }

    start () {

    }

    onClicked(){
        let node: cc.Node = cc.find('Canvas/hero');
        let script = node.getComponent('heroScript');
       
        if(this.toLeft){
            //script.can_moveCon();
            script.moveLeft();
        }
        if(this.toRight){
            //script.can_moveCon();
            script.moveRight();
        }
        if(this.toUp){
            //script.can_moveCon();
            script.moveUp();
        }
        if(this.toDown){
            //script.can_moveCon();
            script.moveDown();
        }
    }
    // update (dt) {}
}